<?php


namespace App\Services;


use App\Models\SchoolCollectModel;

class SchoolService
{
    //添加学校信息
    public function addSchoolInfo($inputs){

        $insertData = [];
        foreach ((new SchoolCollectModel())->addFiled as $filed) {
            if($filed == 'uid'){
                $insertData['uid'] = isset($inputs[$filed])?$inputs[$filed]:"1";
            }else{
            $insertData[$filed] = $inputs[$filed];
            }
        }
        try {
            //开始添加学校
            $schoolId = (new SchoolCollectModel())->insertGetId($insertData);
            if (empty($schoolId)) {
                throw new \RuntimeException('抱歉！添加失败！');
            }
            logger("添加成功<====>" . $inputs['school_title'] ?? "" . '---->' . $inputs['school_title'] ?? "");
            return $schoolId;
        }catch (\Exception $e){
            x($e->getMessage());
        }
    }
}